package kursynbp;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

public class Country {

	private String name;
	
	public Country(String name) {
		this.name = name;
	}
	
	public Country(CountryDAO cd) {
		this.name = cd.getName();
	}
	
	public String getName() {
		return this.name;
	}
	
	public void addCurrency(Connection connection, Exchange ex) {
		CountryDAO crd = new CountryDAO(getName());
		ExchangeDAO ed = new ExchangeDAO(ex.getCode());
		crd.addCurrency(connection, ed);
	}
	
	public List<Country> getCountriesWithMultipleCurrencies(Connection connection) {
		List<CountryDAO> lcd = CountryDAO.findCountriesWithMultipleCurrencies(connection);
		List<Country> retList = new ArrayList<Country>();
		
		for (CountryDAO cd : lcd) {
			retList.add(new Country(cd));
		}
		
		return retList;
	}
}
